############
# OVERVIEW #
############

This readme file contains instructions for executing the replication script for 
"Explaining Rural Conservatism: Political Consequences of Technological Change in the Great Plains". 

There are two main R scripts. The first is "data_processing_script.R" and the second is "analysis_script.R". 
The first script takes several raw datafiles as input and as output produces intermediate datasets needed 
for analysis. 

The second script takes these intermediate datasets as inputs and executes the statistical analyses reported 
in the paper. The second script may be run directly as the intermediate datasets are provided
with the replication data. The user can also re-produce the intermediate datasets by running the first script
before running the second script. 

#########################################################
# SOFTWARE, DATASETS AND SCRIPTS NEEDED FOR REPLICATION #
#########################################################

All analyses were completed in R version 4.1.2. Each script contains a list of required R packages. 
Please install these packages before running the scripts. 

To replicate the figures and tables in the paper, please save all files contained in the dataverse
to a directory on your computer. This directory should consist of three subfolders. These subfolders
are "input_files", "output_files", and "output_figures". 

PLEASE NOTE THAT the "input_files" folder should be downloaded separately at the following link:
https://www.dropbox.com/scl/fo/2uuh6yp2d6ekoprpd3tq4/h?rlkey=19ugkjhxw0y8qbxfmx5gskj8q&dl=0

In each script, you must set your path to to the directory in your computer where these subfolders
are contained. 

The folder "input_files" contains the raw data that is processed by script "data_processing_script.R". 
The folder "output_files" contains the intermediate datasets that are taken as input by "analysis_script.R". 
The folder "output_figures" is where figures and tables from the main paper are saved.


###################
# FOLDER CONTENTS #
###################

############
# RAW DATA #
############

Raw data are stored in the input_files folder. Files and subfolders include:

nhgis0001_shape -- a folder containing decadal shapefiles of US county boundaries 1900-1990

Source: Steven Manson, Jonathan Schroeder, David Van Riper, Katherine Knowles, Tracy Kugler, Finn Roberts, and Steven Ruggles. 
IPUMS National Historical Geographic Information System: Version 18.0 [dataset]. Minneapolis, MN: IPUMS. 2023. http://doi.org/10.18128/D050.V18.0

aquifer -- a folder consisting of shapefile data for the Ogallala aquifer

Source:  Qi, S.L., 2009, Digital map of aquifer boundary for the High Plains aquifer in parts of Colorado, Kansas, Nebraska, New Mexico, Oklahoma, South Dakota, Texas, and Wyoming: 
U.S. Geological Survey data release, https://doi.org/10.5066/P9KA17IW 

County_Level_US_Elections_Data -- a folder consisting of county-level electoral data

Source: Amlani, Sharif, and Carlos Algara. "Partisanship & nationalization in American elections: Evidence from presidential, senatorial, & gubernatorial elections in the US counties, 1872–2020." 
Electoral Studies 73 (2021): 102387.

ICPSR_04254 -- a folder consisting of agricultural census data

Source: Gutmann, Myron P. Great Plains Population and Environment Data: Agricultural Data, 1870-1997 [United States]. 
Inter-university Consortium for Political and Social Research [distributor], 2005-06-22. https://doi.org/10.3886/ICPSR04254.v1

ICPSR_04296 -- a folder consisting of population census data

Source: Gutmann, Myron P. Great Plains Population and Environment Data: Social and Demographic Data, 1870-2000 [United States]. 
Inter-university Consortium for Political and Social Research [distributor], 2007-02-07. https://doi.org/10.3886/ICPSR04296.v2

religion_data -- a folder consisting of religious census data

Source: The Association of Religion Data Archives: https://www.thearda.com/

race -- a folder consisting of racial composition data from the us census

Source: IPUMS NHGIS: https://www.nhgis.org/overview-nhgis-datasets

covariates.RData -- an R file consisting of county level covariates

Source: 1940 full count census, maps from the national archives, authors' analyses. Please
note that this involves very large raw data files. Please contact the author for the raw data 
and code used to process this raw data. 

deep_learning -- a folder consisting of various files related to computer vision estimates of technology adoption

Source: Authors' analyses, Landsat 5 satellite imagery processed n Google Earth Engine.  Please
note that this involves very large raw data files as well as large deep learning models. 
Please contact the author for the raw data and code used to process this raw data. 

CCES_data -- a folder consisting of Cooperative Congressional Election Study data

Source: Kuriwaki, Shiro. 2021. “Cumulative CCES Common Content (2006-2020).” URL: https://doi.
org/10.7910/DVN/II2DB6.

zip_code -- a folder consisting of zip code shapefiles

Source: https://www.census.gov/geographies/mapping-files/time-series/geo/carto-boundary-file.html

dime -- a folder consisting of DIME data

Source: Database on Ideology, Money in Politics, and Elections (DIME): Public
version 2.0 (https://data.stanford.edu/dime).

##################
# PROCESSED DATA #
##################

Intermediate datasets are stored in the output_files folder:

county_list.RData -- an R data file consisting of combined decadal county shapefiles

aquifer.Rdata -- an R data file consisting of a shapefile of the Ogallala aquifer boundary 

aquifer_line.Rdata -- an R data file consisting of a spatial lines version of the Ogallala aquifer boundary

states.Rdata -- an R data file consisting of a shapefile of state boundaries

county_panel.RData -- an R data file consisting of a panel shapefile of county boundaries

pres_data.RData -- an R data file consisting of county-level presidential election results

sen_data.RData -- an R data file consisting of county-level senatorial election results

gov_data.RData -- an R data file consisting of county-level gubernatorial election results

agdat.RData -- an R data file consisting of agricultural panel data

popdat.RData -- an R data file consisting of census panel data

religion_dat -- an R data file consisting of religious census panel data

race.RData -- an R data file consisting of racial composition panel data

county_frame.RData -- an R data file consisting of a data frame with information on county boundary stability over time

dat.Rdata -- an R data file consisting of a two-period panel dataset on elections and aquifer coverage

dat200.Rdata -- an R data file consisting of a two-period panel dataset on elections and aquifer coverage, 
pruned to counties within 200km of the Ogallala aquifer boundary

dat100.Rdata -- an R data file consisting of a two-period panel dataset on elections and aquifer coverage, 
pruned to counties within 100km of the Ogallala aquifer boundary

zip_sample.RData -- an R data file consisting of shapefiles of zip code boundaries

tab5.Rdata -- an R data file consisting of data on individual policy preferences and aquifer coverage at zip code level

alt_dat.Rdata -- an R data file consisting of a two-period panel dataset on elections and aquifer coverage with alternate endline (2000-2020)

alt_dat200.Rdata-- an R data file consisting of a two-period panel dataset on elections and aquifer coverage with alternate endline (2000-2020), 
pruned to counties within 200km of the Ogallala aquifer boundary

alt_dat100.Rdata-- an R data file consisting of a two-period panel dataset on elections and aquifer coverage with alternate endline (2000-2020), 
pruned to counties within 100km of the Ogallala aquifer boundary

cf_scores.RData -- an R data file consisting of CF score data linked to aquifer coverage data

#############################
# OUTPUT FIGURES AND TABLES #
#############################

output_figures folder: 

fig1.jpg -- Figure 1 from paper

fig2.jpg -- Figure 2 from paper

fig3b.jpg -- Figure 3 from paper

fig3c.jpg -- Figure 3 from paper

fig3d.jpg -- Figure 3 from paper

fig4.jpg -- Figure 4 from paper

fig5.pdf -- figure 5 from paper

fig6.pdf -- figure 6 from paper

fig7.pdf -- figure 7 from paper

fig8.jpg -- figure 8 from paper

table1_panelA.txt -- table 1 from paper

table1_panelB.txt  -- table 1 from paper

table1_panelC.txt -- table 1 from paper

table2.txt -- table 2 from paper

table3.txt -- table 2 from paper

table4.txt -- table 2 from paper

table5_panelA.txt - table 5 from paper

table5_panelB.txt -- table 5 from paper

table5_panelC.txt -- table 5 from paper

table5_panelD.txt -- table 5 from paper

*note that the replication script also contains the code for
producing figures and tables in the Online Appendix but 
these output are not automatically saved in this folder

